package com.situ.mymall.controller;

import com.situ.mymall.pojo.entity.Order;
import com.situ.mymall.pojo.query.OrderQuery;
import com.situ.mymall.service.IOrderService;
import com.situ.mymall.util.PageResult;
import com.situ.mymall.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @RequestMapping("/selectByPage")
    public PageResult selectByPage(OrderQuery orderQuery){
        return orderService.selectByPage(orderQuery);
    }

    @RequestMapping("/selectById")
    public Result selectById(Long orderNo){
        Order order = orderService.selectById(orderNo);
        return Result.ok(order);
    }

    @RequestMapping("/add")
    public Result add(Order order){
        orderService.add(order);
        return Result.ok("添加成功");
    }

    @RequestMapping("/deleteById")
    public Result deleteById(Integer id){
        orderService.deleteById(id);
        return Result.ok("删除成功");
    }

    @RequestMapping("/deleteAll")
    public Result deleteAll(Integer[] ids){
        orderService.deleteAll(ids);
        return Result.ok("删除成功");
    }

    @RequestMapping("/update")
    public Result update(Order order){
        orderService.update(order);
        return Result.ok("更新成功");
    }




}
